home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / others / ole_101.zip / SCHMOO.ZIP / OLEFILE.C < prev    next >
C/C++ Source or Header  |  1992-04-13  |  2KB  |  82 lines

  1. /*
  2.  * OLEFILE.C
  3.  *
  4.  * Functions for handling special case OLE functions for operations
  5.  * on a File menu such as New, Open, Save, SaveAs, and Exit.
  6.  *
  7.  * Functions:
  8.  *  PDocRevokeAndCreate
  9.  *
  10.  * Copyright(c) Microsoft Corp. 1992 All Rights Reserved
  11.  *
  12.  */
  13.  
  14. #ifdef MAKEOLESERVER
  15.  
  16. #include <windows.h>
  17. #include <ole.h>
  18. #include "schmoo.h"
  19. #include "oleglobl.h"
  20.  
  21.  
  22.  
  23. /*
  24.  * PDocRevokeAndCreate
  25.  *
  26.  * Purpose:
  27.  *  Standard sequence of calling OleRevokeServerDoc, allocating and
  28.  *  initializing a new OLESERVERDOC structure, and calling
  29.  *  OleRegisterServerDoc.
  30.  *
  31.  * Parameters:
  32.  *  pOLE            LPXOLEGLOBALS pointer to OLE global variables.
  33.  *
  34.  * Return Value:
  35.  *  LPSCHMOODOC     Pointer to the new document, or NULL if it fails.
  36.  *
  37.  */
  38.  
  39. LPSCHMOODOC FAR PASCAL PDocRevokeAndCreate(LPXOLEGLOBALS pOLE)
  40.     {
  41.     LPSCHMOODOC     pDoc;
  42.     OLESTATUS       os;
  43.  
  44.     os=OleRevokeServerDoc(pOLE->pSvr->pDoc->lh);
  45.  
  46.     /*
  47.      * Even through we are revoking the document, the server will also
  48.      * be Released (through not revoked) since no OLE connections will
  49.      * exist to the server.  Since ServerRelease in this application
  50.      * frees the allocated document, we need to wait until we pass
  51.      * ServerRelease before allocating a new document.  Otherwise we'd
  52.      * allocate a new one and ServerRelease would immediately free it.
  53.      *
  54.      * So in calling FOLEReleaseWait we watch the server's fRelease flag.
  55.      */
  56.  
  57.     if (OLE_WAIT_FOR_RELEASE==os)
  58.         {
  59.         pOLE->pSvr->fRelease=FALSE;
  60.         FOLEReleaseWait(&pOLE->pSvr->fRelease, pOLE->pSvr->lh);
  61.         }
  62.  
  63.     pDoc=PDocumentAllocate(&pOLE->vtblDoc);
  64.     pOLE->pSvr->pDoc=pDoc;
  65.  
  66.     if (NULL==pDoc)
  67.         return NULL;
  68.  
  69.     os=OleRegisterServerDoc(pOLE->pSvr->lh, pGlob->szFile,
  70.                             (LPOLESERVERDOC)pOLE->pSvr->pDoc,
  71.                             &pOLE->pSvr->pDoc->lh);
  72.  
  73.     pOLE->pSvr->fLink=FALSE;
  74.     pOLE->pSvr->fEmbed=FALSE;
  75.  
  76.     MenuEmbeddingSet(pGlob->hWnd, NULL, FALSE);
  77.     return pDoc;
  78.     }
  79.  
  80.  
  81. #endif //MAKEOLESERVER
  82.